<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
	<script>var ctx="${ctx}";</script>
	<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	    <title>分类管理</title>
	    <meta name="keywords" content="">
	    <meta name="description" content="">
	    <meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
		<meta http-equiv="expires" content="Wed, 26 Feb 209908:21:57 GMT"> 
	    
		<link rel="shortcut icon" href="favicon.ico"> 
		<link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/font-awesome.min.css?v=4.4.0?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/footable/footable.core.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/summernote/summernote.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/summernote/summernote-bs3.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/plugins/laypage/laypage.css?v=${static_version}"  rel="stylesheet">
		<link href="${ctx}/static/css/plugins/iCheck/custom.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/chosen/chosen.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/animate.min.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/js/plugins/layer/laydate/laydate.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/webuploader/webuploader.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/switchery/switchery.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/style.min.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/js/plugins/uploadify/uploadify.css?v=${static_version}/" rel="stylesheet">
	    
	</head>
	<body class="gray-bg">
    	<div class="ibox float-e-margins">
    		<div class="ibox-content">
                <form class="form-group" id="goodsCat_table_form">	
                	<input type="hidden" id="goodsCat-select-id" name="goodsCat-select" value="">
                	<div class="row">
                		<perm:hasPermission code="goodsCat/find">
                        <div class="col-md-2"><input name="keyword" type="text" placeholder="请输入名称" class="form-control" /></div>
						<div class="col-md-1 col-sm-2">
							<button id="goodsCat_table_search" type="button" class="btn btn-outline btn-block btn-primary">查询</button>
						</div>
						</perm:hasPermission>
						<perm:hasPermission code="goodsCat/insertGet">
					    <div class="col-md-1  col-sm-2 pull-right ">
							<a  onclick="clickInsertGet()" class="btn btn-block btn-outline btn-primary">添加</a>
					    </div>
					    </perm:hasPermission>
                    </div>
                </form>
				<table id="goodsCat_table" data-action="${ctx}/goodsCat/find" data-datatable="true"  class="footable table table-stripped toggle-arrow-tiny">
				  	<thead>
					  	<tr>
							<th data-sort-ignore="true"  data-title="name" >名称</th>
					  		<th  data-sort-ignore="true" data-title ="image" data-hide="phone,tablet" data-type="callback" data-callback="initUserImage">图片</th>
							<th data-sort-ignore="true"  data-title="sort"  data-hide="phone,tablet">排序</th>
						  	<th data-sort-ignore="true"  data-crud="true" data-title='{"uid":"id"}' data-hide="phone">操作
			      			  <div style="display: none;" class="center hidden-phone">
			      			  	 <perm:hasPermission code="goodsCat/updateGet">
			      			  	 	<button onclick="clickUpdateGet(this)" data-id=":uid" type="button" style="margin-right:5px" class="btn btn-info btn-outline btn-xs"><i class="fa fa-pencil"></i>&nbsp;更新</button>
			      			  	 </perm:hasPermission>
			      			  	 <perm:hasPermission code="goodsCat/delete">
					      			  		<button onclick="deleteAjax(this)" data-url="${ctx}/goodsCat/delete" style="margin-left:3px;" data-id=":uid" type="button" class="btn btn-danger btn-outline btn-xs"><i class="fa fa-times"></i>&nbsp;删除</button>
								 </perm:hasPermission>
							  </div> 
		      		      	</th>
					  	</tr>
				  	</thead>
				  	<tbody>
				  	</tbody>
			  	</table>
			  	<div class="row">
			  		<div class="col-md-6" class="pull-left" id="page_left_text"></div>
			  		<div class="col-md-6"  id="page_text"></div>
			  	</div>
			</div>
		</div>
		
	<script src="${ctx}/static/js/jquery.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/bootstrap.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/footable/footable.all.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/validate/jquery.validate.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/validate/messages_zh.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/webuploader/webuploader.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote-zh-CN.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/chosen/chosen.jquery.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/layer/laydate/laydate.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/iCheck/icheck.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/plugins/laypage/laypage.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/switchery/switchery.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/eModal.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/cookie.js?v=?v=${static_version}"></script>
	<script src="${ctx}/static/common/custom-datatable.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/content.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/contabs.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/common/common.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/ueditor-1.4.3/ueditor.config.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/ueditor-1.4.3/ueditor.all.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/uploadify/jquery.uploadify.js?v=${static_version}"></script>
	
	<script>

	var initUserImage=function(cData,cLable,row){
		if(cData!=null&&cData!=""){
		  return '<img alt="image" class="img-circle message-avatar" src="'+cData+'">';
		}else{
			return"无图片";
		}
	}
		$(document).ready(function() {
			init_page_datatable();
		});
		var getOrgrtBy=function(){
			eModal.ajax({
	   	        url: "${ctx}/goodsCat/find",
	   	        title:'添加分类',
	   	        loading:true,
	   	        subtitle: '',
	   	        data:{
					id:$("#id").val(),							
					keyword:$("#keyword").val(),							
					sort:$("#sort").val(),	
					name:$("#name").val(),		
					token:$("#token").val(),		
	   	        }
	   	    });
		}
		var clickUpdateGet=function(me){
			eModal.ajax({
	   	        url: "${ctx}/goodsCat/updateGet?id="+$(me).data("id"),
	   	        title:'修改分类',
	   	        loading:true,
	   	        subtitle: '',
	   	        buttons: [
	   	            {text:'保存',style:'info',close:false,click:function(){
		   	 			if (!jQuery.checkall(true)) return;
		   	     		var images=[];
		   	 			$(".imageUploadify img").each(function(){
		   					images.push($(this).attr("src"));
		   				})
		   				var specs=[];
		   	 			$("#specsDiv [type='checkbox']:checked").each(function(){
		   	 				specs.push($(this).val());
		   	 			})
	   	 		    	$.ajax({  
	   	 					url:'${ctx}/goodsCat/update',  
	   	 					data:{
								name:$("#name").val(),							
								image:images.toString(),							
								sort:$("#sort").val(),
								specs:specs.toString(),
								id:$("#id").val()
							},   
							type: 'POST',
	   	 					dataType:'json',  
	   	 					success:function(response){
	   	 						if(response.code==0){
	   	 							eModal.close();
	   	 							$("#goodsCat_table_search").click();
	   	 						}else{
	   	 						    $.confirm({cancelButton: "关   闭",title: '提示!',content: "添加分类错误!"});
	   	 						}
	   	 					}  
	   	 			    }); 
	   	            }},{text: '取消', style: 'danger', close: false, click:function(){
	   	            	eModal.close();
	   	            }}
	   	        ],
	   	    });
		}
		
		var clickInsertGet=function(){
			eModal.ajax({
	   	        url: "${ctx}/goodsCat/insertGet",
	   	        title:'添加分类',
	   	        loading:true,
	   	        subtitle: '',
	   	        buttons: [
	   	            {text: '保存',style:'info',close:false,click:function(){
		   	 			if (!jQuery.checkall(true)) return;
		   	     		var images=[];
		   	 			$(".imageUploadify img").each(function(){
		   					images.push($(this).attr("src"));
		   				})
		   				var specs=[];
		   	 			$("#specsDiv [type='checkbox']:checked").each(function(){
		   	 				specs.push($(this).val());
		   	 			})
	   	 		    	$.ajax({  
	   	 					url:'${ctx}/goodsCat/add',  
	   	 					data:{
								name:$("#name").val(),								
								image:images.toString(),							
								sort:$("#sort").val(),
								specs:specs.toString(),
								id:$("#id").val()
							},   
							type: 'POST',
	   	 					dataType:'json',  
	   	 					success:function(response){
	   	 						if(response.code==0){
	   	 							eModal.close();
	   	 							$("#goodsCat_table_search").click();
	   	 						}else{
	   	 						    $.confirm({cancelButton: "关   闭",title: '提示!',content:"修改分类错误!"});
	   	 						}
	   	 					}  
	   	 			    }); 
	   	            }},{text: '取消', style: 'danger', close: false, click:function(){
	   	            	eModal.close();
	   	            }}
	   	        ],
	   	    });
		}
		
		$(function(){
		
			jQuery.searchFormInit();
		});
	</script>
	
	</body>
</html>